##!/usr/bin/env python3
# -*- coding: utf-8 -*-

def fib(max):
    n, a, b = 0, 0, 1
    while n < max:
        yield (b)
        a, b = b, a + b
        n = n + 1
    return 'done'

print(fib(10))

g=fib(10)

for n in g:
    print(n)

while True:
    try:
        x = next(g)
        print(x)
    except StopIteration as e:
        print(e.value)
        break